@RestController
public class HelloController {

    @RequestMapping("hello")
    public BaseRespVo hello() {
        return BaseRespVo.ok("hello world");
    }

    public HelloController() {
        System.out.println("controller init");
    }

    /*如果是这样的userService是应用程序创建的，应用程序没有去维护 UserService和userDao之间的关系，这样获得的userService实例
     他的userDao userMapper是一个nu'l'l，会空指针异常不是Sping*/
    //UserService userService = new UserServiceImpl();
    @Autowired
    UserService userService;

    @RequestMapping("user/query/{id}")
    public BaseRespVo queryUser(@PathVariable("id") Integer id) {
        User user = userService.queryUserById(id);
        return BaseRespVo.ok(user);
    }
}
